﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Threading;

namespace PresentItNow
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            Closed += new EventHandler(MainWindow_Closed);

            

            
        }

        void MainWindow_Closed(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            viewModel = new ViewModel(this);

            DataContext = viewModel;

            this.CommandBindings.Add(viewModel.StartHost);
            this.CommandBindings.Add(viewModel.StopHost);
            this.CommandBindings.Add(viewModel.StartClient);
            this.CommandBindings.Add(viewModel.Connect);
            this.CommandBindings.Add(viewModel.Disconnect);

            viewModel.ShowMarker += viewModel_ShowMarker;            
        }

        MarkerWindow viewModel_ShowMarker(string name, int colorNumber)
        {
            MarkerWindow window = new MarkerWindow(name, colorNumber);
            //window.Owner = this;
            window.Show();
            return window;
        }

        ViewModel viewModel = null;

        private void menuAbout_Clicked(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(@"PresentItNow!

A simple screen sharing tool.

Created By: Ralf Hoffmann
Date: July 2011

Version 0.31
", "About");
        }

        

        
    }
}
